<?php

namespace app\utils\base\plugin\tags;

class Tag_show_file_plugin
{
    /**
     * 展示文件目录
     */
    public function show($paramObj="")
    {
        $dataObj=paramsObj();
        $dataObj->request=paramsObj();
        $dataObj->data=paramsObj();

        $final_arr=logInit();
        if($final_arr["error_no"]==0){
            $mixed=parseToArr($paramObj,"mixed",0);
            $params=parseToArr($paramObj,"params",array());
            $messages=parseToArr($paramObj,"messages",array());
            $rules=array(
                'extraData' => '',
            );
            $dataDefault=array();
            $paramsObj=paramsObj();
            $paramsObj->params=$params;
            $paramsObj->mixed=$mixed;
            $paramsObj->rules=$rules;
            $paramsObj->messages=$messages;
            $paramsObj->dataDefault=$dataDefault;
            $checkResult = app("verifyParam")::validatorRequest($paramsObj);
            if($checkResult["error_no"]==0){
                $dataObj->request=$checkResult["result"];
            }else{
                $final_arr=logCallErrorMsg($final_arr,$checkResult);
            }
        }
        if($final_arr["error_no"]==0)
        {
            $condition=app("P_tag_plugin")->parseCondition($dataObj->request->extraData);
            $dir=isset($condition["dir"])?$condition["dir"]:"";
            $resourceDir=isset($condition["resourceDir"])?$condition["resourceDir"]:"";
            $config=(isset($condition["config"]) && $condition["config"])?toJsonDecode($condition["config"]):array();
            if($config){
                $files=$dir?app("ltcmsZip")->getFileByConfig($dir,$config):array();
                if($files){
                    $html=app("ltcmsFormat")->showDirByData($files,$resourceDir,1);  //转换成html
                }else{
                    $html="";
                }
            }else{
                $files=$dir?app("ltcmsZip")->files($dir):array();
                if($files){
                    $html=app("ltcmsFormat")->showDir($files,$resourceDir,1);  //转换成html
                }else{
                    $html="";
                }
            }
            $return=array();
            $return["result"]=$html;
            $final_arr["result"]=$return;
        }
        return $final_arr;
    }

    public function __call($name,$arguments)
    {
        return recordLogMsgLevelTwo(app("errorLevel")::E_WARNING,app("errorCode")::UNDEFINED_METHOD,lang("sys.noMethodDefined"),$name,$arguments);
    }
}

?>